package metro.cards;


import metro.cards.types.CardSpecialType;
import metro.cards.types.CardType;
import metro.system.IdGenerator;
import metro.response.Response;
import metro.system.MetroSystem;
import metro.tourniquet.Tourniquet;

import java.util.Calendar;

public abstract class Card implements Comparable<Card> {
    protected CardSpecialType specialType;
    protected CardType type;
    protected long id;
    protected Calendar creationDate;

    protected Card(Calendar creationDate) {
        this.id = IdGenerator.generateId();
        this.creationDate= creationDate;
        specialType=CardSpecialType.COMMON;
    }

    public long getId() {
        return id;
    }

    public abstract Response use(MetroSystem system,Tourniquet tourniquet);

    public CardSpecialType getSpecialType() {
        return specialType;
    }

    public CardType getType() {
        return type;
    }

    @Override
    public int compareTo(Card o) {
        return (int)Math.signum(id-o.id);
    }

    @Override
    public int hashCode() {
        return (int)id;
    }

    @Override
    public boolean equals(Object obj) {
        return obj instanceof Card && id == ((Card) obj).id;
    }
}
